package com.elink.enginerring.util;

public class VersionComparator{
	/**
	 * @param oldVersion  当前手机运行版本
	 * @param newVersion 新版本
	 * @return false -- 新版本低于当前手机运行版本
	 */
	public static boolean cpVersion(String oldVersion, String newVersion){
		if (oldVersion.compareTo(newVersion) == 0) {
			return false;
		}
		String[] versionArray1 = oldVersion.split("\\.");
		String[] versionArray2 = newVersion.split("\\.");
		int minLength = Math.min(versionArray1.length, versionArray2.length);
		for (int i = 0; i < minLength; i++) {
			if (versionArray1[i].length() - versionArray2[i].length() == 0) {
				if (versionArray1[i].compareTo(versionArray2[i]) > 0)
					return false;
				else if (versionArray1[i].compareTo(versionArray2[i]) < 0)
					return true;
				else {
					continue;
				}
			} else if (versionArray1[i].length() - versionArray2[i].length() > 0) {
				return false;
			} else {
				return true;
			}
		}
		return versionArray1.length - versionArray2.length > 0 ? false: true;
	}
	
	public static void main(String[] args) {
		System.out.println(cpVersion("6.11","7.2")); 
		//false 版本不更新，
	}
}